﻿using Microsoft.AspNetCore.Http;
using System;
using NLog;
using System.Collections.Generic;
using Microsoft.Extensions.Configuration;

namespace netcore_comm.Nlog
{
    public sealed class NLogHelper : INLogHelper
    {
        private static Logger _logger = LogManager.GetCurrentClassLogger();
        private readonly IConfiguration _configuration;

        public NLogHelper(IConfiguration configuration)
        {
            _configuration = configuration;
        }

        /// <summary>
        /// 获取CorrelationId
        /// </summary>
        /// <returns></returns>
        //public Dictionary<string, string> GetCorrelationId()
        //{
        //    Dictionary<string, string> d = new Dictionary<string, string>();
        //    d.Add("X-Correlation-Id", _correlationContext.CorrelationContext.CorrelationId);
        //    return d;
        //}

        #region 获取链路ID
        private string GetNewMsg(string Msg)
        {
          
            return $"{Msg}";
        }
        #endregion
        public void Trace(string msg)
        {
            _logger.Trace(GetNewMsg(msg));
        }

        public void Debug(string msg)
        {
            _logger.Debug(GetNewMsg(msg));
        }

        public void Info(string msg)
        {
            _logger.Info(GetNewMsg(msg));
        }

        public void Warn(string msg)
        {
            _logger.Warn(GetNewMsg(msg));
        }

        public void Error(string msg)
        {
            _logger.Error(GetNewMsg(msg));

        }
        public void Error(Exception ex)
        {
            _logger.Error(GetNewMsg(ex.ToString()));
        }


        public void Fatal(string msg)
        {
            _logger.Fatal(GetNewMsg(msg));
        }
    }
}
